# 单例模式

# class Student:
#     pass
#
# s = Student()
# s2 = Student()
#
# print(s)
# print(s2)

class Singleton:
    # 私有化
    __instance = None
    name = "jack"

    def __init__(self):
        print("-----init------")

    # 重写__new__
    def __new__(cls, *args, **kwargs):
        print("--------new----------")
        if cls.__instance is None:
            cls.__instance = object.__new__(cls)
        return cls.__instance
    def show(self, n):
        print('------------------>show', Singleton.name, n)

s = Singleton()
s1 = Singleton()
print(s)
print(s1)
s.show(5)
s1.show(6)
